//
//  DaysPriceCollectionCell.m
//  ProjectA_LK
//
//  Created by 萌萌的小坤坤 on 16/6/16.
//  Copyright © 2016年 冷坤. All rights reserved.
//

#import "DaysPriceCollectionCell.h"
#import "UIImageView+WebCache.h"
#define WIDTH self.view.frame.size.width

#define HEIGHT self.view.frame.size.height

#define COLORS [UIColor colorWithRed:(arc4random() % 256 / 255.0) green:(arc4random() % 256 / 255.0) blue:(arc4random() % 256 / 255.0) alpha:1.0];


@implementation DaysPriceCollectionCell
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self creatOneCollection:frame];
    }
    return self;
}

- (void)creatOneCollection:(CGRect)frame{
    
    self.picImage = [[UIImageView alloc]initWithFrame:CGRectMake(10, 10, self.frame.size.width - 40 / 3, self.frame.size.width - 40 / 3)];
    [self.contentView addSubview:self.picImage];
    [_picImage release];
    
    self.contextLabel = [[UILabel alloc]initWithFrame:CGRectMake(self.picImage.frame.origin.x, self.picImage.frame.origin.y + 10 + self.picImage.frame.size.height, self.picImage.frame.size.width, self.picImage.frame.size.height / 2)];
    self.contextLabel.font = [UIFont systemFontOfSize:12.0];
    self.contextLabel.textColor = [UIColor grayColor];
    self.contextLabel.numberOfLines = 2;
    [self.contentView addSubview:self.contextLabel];
    [_contextLabel release];
    
    self.lineView = [[UILabel alloc]initWithFrame:CGRectMake(self.contextLabel.frame.origin.x, self.contextLabel.frame.origin.y + 2 + self.contextLabel.frame.size.height, self.contextLabel.frame.size.width, 1)];
    self.lineView.backgroundColor = [UIColor grayColor];
    self.lineView.alpha = 0.3;
    [self.contentView addSubview:self.lineView];
    [_lineView release];
    
    self.priceLabel = [[UILabel alloc]initWithFrame:CGRectMake(self.lineView.frame.origin.x, self.lineView.frame.origin.y + 3, self.lineView.frame.size.width, self.picImage.frame.size.height / 4)];
    self.priceLabel.font = [UIFont systemFontOfSize:14.0];
    self.priceLabel.textColor = [UIColor redColor];
    [self.contentView addSubview:self.priceLabel];
    [_priceLabel release];
    
}

- (void)setModels:(Best *)models{
    if (_models != models) {
        [_models release];
        _models = [models retain];
    }
    [self.picImage sd_setImageWithURL:[NSURL URLWithString:models.picurl]];
    self.contextLabel.text = models.title;
    self.priceLabel.text = [NSString stringWithFormat:@"¥ %@", models.price];
}
- (void)dealloc{
    [_picImage release];
    [_contextLabel release];
    [_lineView release];
    [_picImage release];
    [super dealloc];
}

@end
